package rrrmai.viewbinder;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.Observable;
import android.databinding.PropertyChangeRegistry;
import android.os.Parcel;
import android.os.Parcelable;

import com.xgggh.rrrmai.BR;
import java.io.Serializable;
import rrrmai.model.User;
import rrrmai.utils.Md5;

/**
 * Created by summer on 2018/2/28.
 */
public class Comment  extends BaseObservable implements Parcelable {

    private String userId;
    private String userName;
    private String userMobile;
    private String  price;
    private String  title;
    private String  hint;
    private String  content;
    @Bindable
    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
        notifyPropertyChanged(BR.price);
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }
    @Bindable
    public String getUserId() {
        return userId;
    }

    @Bindable
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
        notifyPropertyChanged(BR.userName);
    }
    @Bindable
    public String getUserMobile() {
        return userMobile;
    }

    public void setUserMobile(String userMobile) {
        this.userMobile = userMobile;
        //gen userId
        this.userId= Md5.getMD5Str(userMobile);
        notifyPropertyChanged(BR.userMobile);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.userId);
        dest.writeString(this.userName);
        dest.writeString(this.userMobile);
        dest.writeString(this.title);
        dest.writeString(this.hint);
        dest.writeString(this.content);
    }

    public Comment() {
    }

    protected Comment(Parcel in) {
        this.userId = in.readString();
        this.userName = in.readString();
        this.userMobile = in.readString();
        this.title = in.readString();
        this.hint = in.readString();
        this.content = in.readString();
    }

    public static final Parcelable.Creator<Comment> CREATOR = new Parcelable.Creator<Comment>() {
        @Override
        public Comment createFromParcel(Parcel source) {
            return new Comment(source);
        }

        @Override
        public Comment[] newArray(int size) {
            return new Comment[size];
        }
    };
}